package cn.xiong.request_hystrix.mapping;

import cn.xiong.request_hystrix.mvc.MvcConfig;
import org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

/**
 * @auther 10349 XIONGSY
 * @create 2021/8/19
 */
@Configuration
@Import({MvcConfig.class, AnnotationAwareAspectJAutoProxyCreator.class})
// 换掉  EnableWebMvc 注解，用自己 MvcConfig 配置类顶替 DelegatingWebMvcConfiguration， 完成  RequestMappingHandlerMapping 替换，@RequestMapping 注解实现逻辑就能替换，用自己的注解 MappingAndCircuit 也能实现一样的功能，并且通过切面 CircuitBreakerAdvisor 中 MappingAndCircuit  拦截到 MappingAndCircuit ，走到advice CircuitBreakerAdvice 增强开启 ControllerhystrixCommand.execute
//@EnableWebMvc
public class AutoConfig {
/*    @Bean
    public HystrixMetricsStreamServlet hystrixMetricsStreamServlet() {
        return new HystrixMetricsStreamServlet();
    }

    @Bean
    public ServletRegistrationBean registration(HystrixMetricsStreamServlet servlet) {
        ServletRegistrationBean registrationBean = new ServletRegistrationBean();
        registrationBean.setServlet(servlet);
        registrationBean.setEnabled(true);//是否启用该registrationBean
        registrationBean.addUrlMappings("/hystrix.stream");
        return registrationBean;
    }*/
}
